<?php
namespace app\common\model;
use think\Model;



class OutStore extends \M
{
  public function goods(){
      return $this->hasOne('Goods','id','goods_id');
  }
  public function store(){
      return $this->hasOne('Store','id','store_id');
  }

  public function searchDatetimeAttr($query, $value, $data){
    if (!empty($value))
    $query->whereTime('create_at','between', $value);
  }
  public function searchGoodsAttr($query, $value, $data){
    if (!empty($value)){
      $id=Goods::where("code",$value)->value("id");
      $query->where('goods_id',$id);
    }

  }
  public function searchStoreAttr($query, $value, $data){
    if (!empty($value)){
      $id=Store::where("code",$value)->value("id");
      $query->where('store_id',$id);
    }
  }

}
